using System;
using System.Collections.Generic;
using System.Text;

using System.Data;
using System.Data.OleDb;


namespace SqlToolkit.Oracle.Schema
{
    public class SqlDbViewField : SqlDbTableFieldBase
    {
        internal SqlDbViewField() { }
        internal SqlDbViewField(OracleDB conn) { _conn = conn; }
        #region VIEW_NAME
        protected string view_name = string.Empty;
        public string ViewName
        {
            get { return view_name; }
            //set{if(value != view_name) view_name = value;}
        }
        #endregion

        internal static SqlDbViewField Build(OracleDB conn, System.Data.IDataReader r)
        {
            SqlDbViewField ret = new SqlDbViewField(conn);

            ret.view_name = (r.IsDBNull(0)) ? string.Empty : r.GetString(0);
            ret.column_name = (r.IsDBNull(1)) ? string.Empty : r.GetString(1);
            ret.data_type = (r.IsDBNull(2)) ? string.Empty : r.GetString(2);
            ret.column_default = (r.IsDBNull(3)) ? string.Empty : r.GetString(3);
            ret.charachter_maximum_length = (r.IsDBNull(4)) ? 0 : r.GetDouble(4);
            ret.ordinal_position = (r.IsDBNull(5)) ? 0 : r.GetDecimal(5);
            ret.data_length = (r.IsDBNull(6)) ? 0 : Convert.ToInt32(r[6]);
            ret.data_precision = (r.IsDBNull(7)) ? 0 : Convert.ToInt32(r[7]);

            return ret;
        }

        internal static SqlDbViewFieldCollection BuildCollection(OracleDB conn, System.Data.IDataReader r)
        {
            SqlDbViewFieldCollection flds = new SqlDbViewFieldCollection();

            while (r.Read())
                flds.Add(SqlDbViewField.Build(conn, r));

            return flds;
        }
    }
}
